<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<button onclick="sendGet()">发送 GET 请求</button>
<button onclick="sendPost()">发送 POST 请求</button>
<button onclick="sendPut()">发送 PUT 请求</button>
<button onclick="sendDelete()">发送 DELETE 请求</button>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script>
    // 正式的 js 代码, 就要调用上面 jQuery 中的方法了.
    function sendGet(){
        $.ajax({
        type: 'get',
        url:'http://127.0.0.1:8080/MethodServlet/method',
        success: function(body) {
            console.log(body)
            console.log('ok');
        }
    });
    }
    function sendPost(){
        $.ajax({
            type: 'post',
            url:'http://127.0.0.1:8080/MethodServlet/method',
            success: function(body) {
            console.log(body);
            console.log('ok');
        }
        });
    }
    function sendPut(){
        $.ajax({
            type: 'Put',
            url:'http://127.0.0.1:8080/MethodServlet/method',
            success: function(body) {
            console.log(body);
            console.log('ok');
        }
        });
    }
    function sendDelete(){
        $.ajax({
            type: 'Delete',
            url:'http://127.0.0.1:8080/MethodServlet/method',
            success: function(body) {
            console.log(body);
            console.log('ok');
            }
    })
    }

</script>
</body>
</html>